/*
 * @Author       : wfl
 * @LastEditors: qiye
 * @description  :
 * @updateInfo   :
 * @Date         : 2023-02-27 11:07:12
 * @LastEditTime: 2023-09-15 11:36:16
 */
import type { RouteRecordRaw } from 'vue-router'
import useSettingsStore from '@g/store/modules/settings'
import { routes as MicroRoutes } from '@micro/router/routes'
import { systemConfig } from '@/system.config'

const { homePage } = systemConfig
// 固定路由（默认路由）
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@main/views/login/login.vue'),
    meta: {
      whiteList: true,
      title: '登录',
      i18n: 'route.login'
    }
  },
  {
    path: '/403',
    name: 'notFound',
    component: () => import('@main/403.vue'),
    meta: {
      title: '无权限'
    }
  },
  {
    path: '/icon-page',
    name: 'IconPage',
    component: () => import('@main/views/icon-page/index.vue'),
    meta: {
      whiteList: true,
      title: '图标库'
    }
  },
  {
    path: '/config-page',
    name: 'ConfigPage',
    component: () => import('@main/views/config-page/index.vue'),
    meta: {
      whiteList: true,
      title: '项目配置'
    }
  },
  ...(MicroRoutes || []),
  {
    path: '/:all(.*)*',
    name: 'notFound',
    component: () => import('@main/[...all].vue'),
    meta: {
      title: '找不到页面'
    }
  }
]

const homeRoute: any = {
  path: '',
  name: 'home',
  meta: {
    title: () => useSettingsStore().settings.home.title,
    i18n: 'route.home',
    icon: 'ant-design:home-twotone',
    breadcrumb: false
  }
}

if (homePage === '/' || homePage === '')
  homeRoute.component = () => import('@main/index.vue')

else
  homeRoute.redirect = homePage

// 系统路由
export const systemRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@main/layouts/index.vue'),
    meta: {
      title: () => useSettingsStore().settings.home.title,
      breadcrumb: false
    },
    children: [
      homeRoute,
      {
        path: 'reload',
        name: 'reload',
        component: () => import('@main/reload.vue'),
        meta: {
          title: '重新加载',
          breadcrumb: false
        }
      },
      {
        path: '/approve-center/approve-list/waitapply',
        name: 'WaitApply',
        component: () => import('@main/views/approve-workflow/ApproveList/WaitApply.vue'),
        meta: {
          title: '审批申请',
          breadcrumb: true,
          breadList: ['approve-center/approve-list'],
          activeMenu: '/approve-center/approve-list'
        }
      },
      {
        path: '/approve-center/approve-configs/edit-form/:id?',
        name: 'EditForm',
        component: () => import('@main/views/approve-workflow/ApproveConfig/Tabs/TabForm.vue'),
        meta: {
          title: '审批流程配置',
          breadList: ['approve-center/approve-configs'],
          breadcrumb: true,
          activeMenu: '/approve-center/approve-configs'
        }
      },
      {
        path: '/news-center/news-template/add-msg-template',
        name: 'AddMsgTemplate',
        component: () => import('@main/views/news-center/news-template/NewsConfig.vue'),
        meta: {
          title: '消息模板配置',
          breadcrumb: true,
          activeMenu: '/news-center/news-template'
        }
      },
      {
        path: '/news-center/news-template/msg-channel-config',
        name: 'ConfigChannelConfig',
        component: () => import('@main/views/news-center/news-template/NewsChannelConfig.vue'),
        meta: {
          title: '模块配置',
          breadcrumb: true,
          activeMenu: '/news-center/news-template'
        }
      }
    ]
  }
]
